package org.kimoji.personal.web;

import java.util.List;

import org.kimoji.entity.Album;
import org.kimoji.personal.service.PersonalService;
import org.kimoji.show.service.ShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PersonalController {
	
	@Autowired
	private PersonalService personalService;
	@Autowired
	private ShowService showService;
	
	@RequestMapping(value="myspace")
	public String myspace(ModelMap modelMap){
		
		List<Album> recommendAlbum = showService.recommendAlbum(null);
		modelMap.put("recommendAlbum", recommendAlbum);
		
		return "personal/myspace";
	}
	
	@RequestMapping(value="myspace/{tag}")
	public String mytab(@PathVariable String tag,ModelMap modelMap){
		modelMap.put("tag", tag);
		if("myattention".equals(tag))
			modelMap.put("dataType", "album");
		else
			modelMap.put("dataType", "video");
		return "personal/mytab";
	}
	
	@RequestMapping(value="{tag}/show/{index}")
	@ResponseBody
	public Object show(@PathVariable String tag,@PathVariable int index){
		if("myattention".equals(tag))
			return showService.showAlbum(0, null, index,null);
		if("mycollect".equals(tag))
			return showService.show(1, null, 1,null);
		if("mycomment".equals(tag))
			return showService.show(1, null, 1,null);
		if("mysupport".equals(tag))
			return showService.show(1, null, 1,null);
		return null;
	}
	
}
